using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace App
{
    public partial class TxtAddr : UserControl
    {
        private Txt txt1;
        private BusyIcon busy1;
    
        public delegate void TextMouseHandle(object sender, KeyEventArgs e);
        public TxtAddr()
        {
            InitializeComponent();
            txt1.AutoCompleteMode = AutoCompleteMode.None;
        }

        public event TextMouseHandle TextMouse;
        protected virtual void OnTextMouse(object sender, KeyEventArgs e)
        {
            if (TextMouse != null)
            {
                TextMouse(sender, e);
            }
        }

        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Category("Appearance")]
        [Description("The text associated with the control.")]
        public override string Text
        {
            get
            {
                return txt1.Text;
            }
            set
            {
                txt1.Text = value;
            }
        }

        public ContextMenuStrip MenuBusy
        {
            get { return busy1.ContextMenuStrip; }
            set { busy1.ContextMenuStrip = value; }
        }

        public bool IsBusy
        {
            get { return busy1.IsBusy; }
            set { busy1.IsBusy = value; }
        }
        

        private void txt1_Leave(object sender, EventArgs e)
        {
            this.BackColor = Color.White;
            txt1.BackColor = Color.White;
        }

        private void TxtAddr_Enter(object sender, EventArgs e)
        {
            this.BackColor = Color.FromArgb(237, 245, 131);
            txt1.BackColor = Color.FromArgb(237, 245, 131);
        }

        private void busy1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && busy1.ContextMenuStrip != null)
            {
                busy1.ContextMenuStrip.Show(Cursor.Position.X, Cursor.Position.Y);
            }
        }

        private void txt1_KeyDown(object sender, KeyEventArgs e)
        {
            OnTextMouse(sender, e);
        }

        private void InitializeComponent()
        {
            this.txt1 = new App.Txt();
            this.busy1 = new App.BusyIcon();
            ((System.ComponentModel.ISupportInitialize)(this.busy1)).BeginInit();
            this.SuspendLayout();
            // 
            // txt1
            // 
            this.txt1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.txt1.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(141)))), ((int)(((byte)(178)))), ((int)(((byte)(227)))));
            this.txt1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.txt1.HotColor = System.Drawing.Color.FromArgb(((int)(((byte)(147)))), ((int)(((byte)(157)))), ((int)(((byte)(9)))));
            this.txt1.Location = new System.Drawing.Point(56, 13);
            this.txt1.Name = "txt1";
            this.txt1.Size = new System.Drawing.Size(222, 20);
            this.txt1.TabIndex = 0;
            this.txt1.TextTip = "";
            // 
            // busy1
            // 
            this.busy1.BackColor = System.Drawing.Color.Transparent;
            this.busy1.IsBusy = false;
            this.busy1.Location = new System.Drawing.Point(15, 9);
            this.busy1.Name = "busy1";
            this.busy1.Size = new System.Drawing.Size(24, 24);
            this.busy1.TabIndex = 1;
            this.busy1.TabStop = false;
            // 
            // TxtAddr
            // 
            this.BackColor = System.Drawing.Color.Transparent;
            this.Controls.Add(this.busy1);
            this.Controls.Add(this.txt1);
            this.Name = "TxtAddr";
            this.Size = new System.Drawing.Size(292, 42);
            ((System.ComponentModel.ISupportInitialize)(this.busy1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }
    }
}
